package com.ld.security.common.mybatis.base.vo;

import com.ld.security.common.mybatis.base.entity.TreeEntity;
import lombok.Data;

import java.util.LinkedList;
import java.util.List;

@Data
public class NodeVo extends TreeEntity<NodeVo> {

    private Object data;

    public NodeVo addChildren(String label,String id) {
        NodeVo node = new NodeVo();
        node.setLabel(label);
        node.setId(id);
        return this.addChildren(node);
    }

        public NodeVo addChildren(NodeVo vo){
        List<NodeVo> children =  this.getChildren();
        if(children == null){
            children = new LinkedList<>();
            this.setChildren(children);
        }
        children.add(vo);
        return vo;
    }

}
